package com.dom.domweb.modular.controller.sysmger;

import com.dom.common.model.vo.basic.*;
import com.dom.domweb.common.RspModel;
import com.dom.domweb.common.TabPager;
import com.dom.domweb.modular.service.StorInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/base")
public class StorInfoController {

    @Autowired
    private StorInfoService storInfoService;
    
    /**
     * 查询仓库信息列表
     * @param limit 每页行数
     * @param page 当前页数
     * @param abbrName 仓库简称
     * @param storCode 仓库代码
     * @return
     */
    @RequestMapping("/getStorInfoList")
    public TabPager getMarketOrderList(@RequestParam("limit")int limit,
                                       @RequestParam("page")int page,
                                       @RequestParam("abbrName")String  abbrName,
                                       @RequestParam("storCode")String  storCode
    ) {
        B099R r = new B099R();
        r.setPn(page);
        r.setPs(limit);
        r.setAbbrName(abbrName);
        r.setStorCode(storCode);
        B099A B099A = storInfoService.findStorInfoList(r);
        return new TabPager(B099A.getStorInfoData(),B099A.getTotalNum());
    }

    /**
     *  新增仓库信息
     * @param request 新增仓库信息对象
     * @return
     */
    @RequestMapping(value="/insertStorInfo", method = RequestMethod.POST)
    public RspModel insertStorInfo(@RequestBody B090R request){
        String storId = storInfoService.insertStorInfo(request);
        return new RspModel(storId);
    }

    /**
     *  查询仓库信息明细列表
     * @param id 仓库信息id
     * @return
     */
    @RequestMapping(value="/updateStorInfoPage", method = RequestMethod.POST)
    public RspModel findUpdateStorInfoPage(@RequestParam("id")String id){
        B093A result = storInfoService.findUpdateStorInfoPage(id);
        return new RspModel(result);
    }

    /**
     * 逻辑删除仓库信息
     * @param id 仓库信息id
     * @return
     */
    @RequestMapping(value = "/storInfoDel",method = RequestMethod.POST)
    public RspModel storInfoDel(@RequestParam("id") String id){
        boolean isTure = storInfoService.storInfoDel(id);
        RspModel model = new RspModel("RSP000000","仓库信息删除成功！");
        if(!isTure){
            model.setRspCode("RSP000001");
            model.setRspMsg("仓库信息删除失败！");
        }
        return model;
    }

    @RequestMapping(value = "/storInfoModify", method = RequestMethod.POST)
    public RspModel storInfoModify(@RequestBody B092R request){
        return storInfoService.storInfoModify(request);
    }
}
